package cn.getech.data.development.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.MultipartResolver;

import javax.servlet.MultipartConfigElement;

@Configuration
@ConditionalOnProperty(name = "data-development.multipart-config", havingValue = "true")
public class MultipartConfig {
    /**
     * 配置文件上传大小
     */
    @Bean
    public MultipartConfigElement multipartConfigElement(){
        MultipartConfigFactory factory = new MultipartConfigFactory();
        //  单个数据大小 500M
        factory.setMaxFileSize("1024000KB");
        /// 总上传数据大小 500M
        factory.setMaxRequestSize("1024000KB");
        return factory.createMultipartConfig();
    }

}
